#include "comm.h"

int main()
{
  umask(0);
  if(mkfifo(MY_FIFO,0666)<0)
  {
    perror("mkfifo");
    return 1;
  }
  int fd=open(MY_FIFO,O_RDONLY);
  if(fd<0)
  {
    perror("open");
    return 2;
  }

  while(1)
  {
    char buffer[64]={0};
    ssize_t s=read(fd,buffer,sizeof(buffer)-1);
    if(s>0)
    {
      buffer[s]=0;
      printf("client: %s\n",buffer);
    }
    else if(s==0)
    {
      printf("client quit....\n");
    }
    else
    {
      perror("read\n");
      break;
    }
  }
  close(2);
  return 0;
}
